package com.yxy.ms.manager.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 配置首页
 */
@Configuration
public class MyAdapter extends WebMvcConfigurationSupport {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor()).excludePathPatterns("/**").excludePathPatterns("/login")
            .excludePathPatterns("/monitor").excludePathPatterns("/main").excludePathPatterns("/templates/**")
            .excludePathPatterns("/static/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/main.shtml").setViewName("main");
        registry.addViewController("/ceshi.shtml").setViewName("ceshi");
        registry.addViewController("/monitor/errorinfo.shtml").setViewName("monitor/errorinfo");
        registry.addViewController("/monitor/a36info.shtml").setViewName("monitor/a36info");
        registry.addViewController("/monitor/a36tollIntervalInfo.shtml").setViewName("monitor/a36tollIntervalInfo");
        registry.addViewController("/monitor/a22UrlMapping.shtml").setViewName("monitor/a22UrlMapping");
        registry.addViewController("/monitor/a22UrlMappingEdit.shtml").setViewName("monitor/a22UrlMappingEdit");

        registry.addViewController("/monitor/m21datasendrecord.shtml").setViewName("monitor/m21datasendrecord");

        registry.addViewController("/monitor/a23DataFile.shtml").setViewName("monitor/a23DataFile");

        // 清分
        registry.addViewController("/clear/tempdata.shtml").setViewName("clear/tempdata");
        registry.addViewController("/clear/editTransGantryEtc.shtml").setViewName("clear/editTransGantryEtc");
        registry.addViewController("/clear/editTransExit.shtml").setViewName("clear/editTransExit");
        registry.addViewController("/clear/messageinfo.shtml").setViewName("clear/messageinfo");
        registry.addViewController("/clear/errormessageinfo.shtml").setViewName("clear/errormessageinfo");
        registry.addViewController("/exception/errorinfo.shtml").setViewName("exception/errorinfo");
        registry.addViewController("/exception/unkown.shtml").setViewName("exception/unkown");
        registry.addViewController("/clear/clearSendRecord.shtml").setViewName("clear/clearSendRecord");
        registry.addViewController("/clear/pendingCharge.shtml").setViewName("clear/pendingCharge");
        registry.addViewController("/clear/clearMessageValidateRecord.shtml")
            .setViewName("clear/clearMessageValidateRecord");

        // 营改增-发票 - 临时表
        registry.addViewController("/cic/billTempData.shtml").setViewName("cic/billTempData");
        registry.addViewController("/cic/billRecord.shtml").setViewName("cic/billRecord");

        registry.addViewController("/clear/rizli.shtml").setViewName("clear/rizli");
        registry.addViewController("/tool/jsonview.shtml").setViewName("tool/jsonview");

        // 定时任务
        registry.addViewController("/task/index.shtml").setViewName("task/index");
        registry.addViewController("/task/add.shtml").setViewName("task/add");
        registry.addViewController("/task/edit.shtml").setViewName("task/edit");
        registry.addViewController("/task/cron.shtml").setViewName("task/cron");
        registry.addViewController("/task/jobTrigger.shtml").setViewName("task/jobTrigger");

        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);

        super.addViewControllers(registry);
    }

}
